import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/case_detail_entity.dart';
import 'package:seedfour/app/models/case_invoice_entity.dart';


CaseDetailEntity $CaseDetailEntityFromJson(Map<String, dynamic> json) {
  final CaseDetailEntity caseDetailEntity = CaseDetailEntity();
  final CaseDetailInfo? caseInfo = jsonConvert.convert<CaseDetailInfo>(
      json['caseInfo']);
  if (caseInfo != null) {
    caseDetailEntity.caseInfo = caseInfo;
  }
  final List<CaseApproveRecord>? approveList = (json['approveList'] as List<
      dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<CaseApproveRecord>(e) as CaseApproveRecord)
      .toList();
  if (approveList != null) {
    caseDetailEntity.approveList = approveList;
  }
  final List<CaseContractFile>? contractFiles = (json['contractFiles'] as List<
      dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<CaseContractFile>(e) as CaseContractFile)
      .toList();
  if (contractFiles != null) {
    caseDetailEntity.contractFiles = contractFiles;
  }
  final List<CaseOrder>? orders = (json['orders'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<CaseOrder>(e) as CaseOrder).toList();
  if (orders != null) {
    caseDetailEntity.orders = orders;
  }
  final List<CaseOrder>? remitOrders = (json['remitOrders'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<CaseOrder>(e) as CaseOrder)
      .toList();
  if (remitOrders != null) {
    caseDetailEntity.remitOrders = remitOrders;
  }
  return caseDetailEntity;
}

Map<String, dynamic> $CaseDetailEntityToJson(CaseDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['caseInfo'] = entity.caseInfo?.toJson();
  data['approveList'] = entity.approveList?.map((v) => v.toJson()).toList();
  data['contractFiles'] = entity.contractFiles?.map((v) => v.toJson()).toList();
  data['orders'] = entity.orders?.map((v) => v.toJson()).toList();
  data['remitOrders'] = entity.remitOrders?.map((v) => v.toJson()).toList();
  return data;
}

extension CaseDetailEntityExtension on CaseDetailEntity {
  CaseDetailEntity copyWith({
    CaseDetailInfo? caseInfo,
    List<CaseApproveRecord>? approveList,
    List<CaseContractFile>? contractFiles,
    List<CaseOrder>? orders,
    List<CaseOrder>? remitOrders,
  }) {
    return CaseDetailEntity()
      ..caseInfo = caseInfo ?? this.caseInfo
      ..approveList = approveList ?? this.approveList
      ..contractFiles = contractFiles ?? this.contractFiles
      ..orders = orders ?? this.orders
      ..remitOrders = remitOrders ?? this.remitOrders;
  }
}

CaseDetailInfo $CaseDetailInfoFromJson(Map<String, dynamic> json) {
  final CaseDetailInfo caseDetailInfo = CaseDetailInfo();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    caseDetailInfo.id = id;
  }
  final String? createdAtStr = jsonConvert.convert<String>(
      json['createdAtStr']);
  if (createdAtStr != null) {
    caseDetailInfo.createdAtStr = createdAtStr;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    caseDetailInfo.name = name;
  }
  final String? caseNameStr = jsonConvert.convert<String>(json['caseNameStr']);
  if (caseNameStr != null) {
    caseDetailInfo.caseNameStr = caseNameStr;
  }
  final String? caseName = jsonConvert.convert<String>(json['caseName']);
  if (caseName != null) {
    caseDetailInfo.caseName = caseName;
  }
  final String? caseTypeStr = jsonConvert.convert<String>(json['caseTypeStr']);
  if (caseTypeStr != null) {
    caseDetailInfo.caseTypeStr = caseTypeStr;
  }
  final String? caseStatus = jsonConvert.convert<String>(json['caseStatus']);
  if (caseStatus != null) {
    caseDetailInfo.caseStatus = caseStatus;
  }
  final String? caseDate = jsonConvert.convert<String>(json['caseDate']);
  if (caseDate != null) {
    caseDetailInfo.caseDate = caseDate;
  }
  final String? takerStr = jsonConvert.convert<String>(json['takerStr']);
  if (takerStr != null) {
    caseDetailInfo.takerStr = takerStr;
  }
  final String? suitType = jsonConvert.convert<String>(json['suitType']);
  if (suitType != null) {
    caseDetailInfo.suitType = suitType;
  }
  final String? lawsuitType = jsonConvert.convert<String>(json['lawsuitType']);
  if (lawsuitType != null) {
    caseDetailInfo.lawsuitType = lawsuitType;
  }
  final String? cico = jsonConvert.convert<String>(json['cico']);
  if (cico != null) {
    caseDetailInfo.cico = cico;
  }
  final String? clientName = jsonConvert.convert<String>(json['clientName']);
  if (clientName != null) {
    caseDetailInfo.clientName = clientName;
  }
  final String? clientCode = jsonConvert.convert<String>(json['clientCode']);
  if (clientCode != null) {
    caseDetailInfo.clientCode = clientCode;
  }
  final String? oppositeName = jsonConvert.convert<String>(
      json['oppositeName']);
  if (oppositeName != null) {
    caseDetailInfo.oppositeName = oppositeName;
  }
  final String? oppositeCode = jsonConvert.convert<String>(
      json['oppositeCode']);
  if (oppositeCode != null) {
    caseDetailInfo.oppositeCode = oppositeCode;
  }
  final String? thirdName = jsonConvert.convert<String>(json['thirdName']);
  if (thirdName != null) {
    caseDetailInfo.thirdName = thirdName;
  }
  final String? thirdCode = jsonConvert.convert<String>(json['thirdCode']);
  if (thirdCode != null) {
    caseDetailInfo.thirdCode = thirdCode;
  }
  final String? archive = jsonConvert.convert<String>(json['archive']);
  if (archive != null) {
    caseDetailInfo.archive = archive;
  }
  final bool? isSignedContract = jsonConvert.convert<bool>(
      json['isSignedContract']);
  if (isSignedContract != null) {
    caseDetailInfo.isSignedContract = isSignedContract;
  }
  return caseDetailInfo;
}

Map<String, dynamic> $CaseDetailInfoToJson(CaseDetailInfo entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['createdAtStr'] = entity.createdAtStr;
  data['name'] = entity.name;
  data['caseNameStr'] = entity.caseNameStr;
  data['caseName'] = entity.caseName;
  data['caseTypeStr'] = entity.caseTypeStr;
  data['caseStatus'] = entity.caseStatus;
  data['caseDate'] = entity.caseDate;
  data['takerStr'] = entity.takerStr;
  data['suitType'] = entity.suitType;
  data['lawsuitType'] = entity.lawsuitType;
  data['cico'] = entity.cico;
  data['clientName'] = entity.clientName;
  data['clientCode'] = entity.clientCode;
  data['oppositeName'] = entity.oppositeName;
  data['oppositeCode'] = entity.oppositeCode;
  data['thirdName'] = entity.thirdName;
  data['thirdCode'] = entity.thirdCode;
  data['archive'] = entity.archive;
  data['isSignedContract'] = entity.isSignedContract;
  return data;
}

extension CaseDetailInfoExtension on CaseDetailInfo {
  CaseDetailInfo copyWith({
    String? id,
    String? createdAtStr,
    String? name,
    String? caseNameStr,
    String? caseName,
    String? caseTypeStr,
    String? caseStatus,
    String? caseDate,
    String? takerStr,
    String? suitType,
    String? lawsuitType,
    String? cico,
    String? clientName,
    String? clientCode,
    String? oppositeName,
    String? oppositeCode,
    String? thirdName,
    String? thirdCode,
    String? archive,
    bool? isSignedContract,
  }) {
    return CaseDetailInfo()
      ..id = id ?? this.id
      ..createdAtStr = createdAtStr ?? this.createdAtStr
      ..name = name ?? this.name
      ..caseNameStr = caseNameStr ?? this.caseNameStr
      ..caseName = caseName ?? this.caseName
      ..caseTypeStr = caseTypeStr ?? this.caseTypeStr
      ..caseStatus = caseStatus ?? this.caseStatus
      ..caseDate = caseDate ?? this.caseDate
      ..takerStr = takerStr ?? this.takerStr
      ..suitType = suitType ?? this.suitType
      ..lawsuitType = lawsuitType ?? this.lawsuitType
      ..cico = cico ?? this.cico
      ..clientName = clientName ?? this.clientName
      ..clientCode = clientCode ?? this.clientCode
      ..oppositeName = oppositeName ?? this.oppositeName
      ..oppositeCode = oppositeCode ?? this.oppositeCode
      ..thirdName = thirdName ?? this.thirdName
      ..thirdCode = thirdCode ?? this.thirdCode
      ..archive = archive ?? this.archive
      ..isSignedContract = isSignedContract ?? this.isSignedContract;
  }
}

CaseApproveRecord $CaseApproveRecordFromJson(Map<String, dynamic> json) {
  final CaseApproveRecord caseApproveRecord = CaseApproveRecord();
  final int? createdAt = jsonConvert.convert<int>(json['createdAt']);
  if (createdAt != null) {
    caseApproveRecord.createdAt = createdAt;
  }
  final int? updatedAt = jsonConvert.convert<int>(json['updatedAt']);
  if (updatedAt != null) {
    caseApproveRecord.updatedAt = updatedAt;
  }
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    caseApproveRecord.id = id;
  }
  final String? caseId = jsonConvert.convert<String>(json['caseId']);
  if (caseId != null) {
    caseApproveRecord.caseId = caseId;
  }
  final String? uid = jsonConvert.convert<String>(json['uid']);
  if (uid != null) {
    caseApproveRecord.uid = uid;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    caseApproveRecord.type = type;
  }
  final int? approve = jsonConvert.convert<int>(json['approve']);
  if (approve != null) {
    caseApproveRecord.approve = approve;
  }
  final String? remark = jsonConvert.convert<String>(json['remark']);
  if (remark != null) {
    caseApproveRecord.remark = remark;
  }
  final String? approverName = jsonConvert.convert<String>(
      json['approverName']);
  if (approverName != null) {
    caseApproveRecord.approverName = approverName;
  }
  return caseApproveRecord;
}

Map<String, dynamic> $CaseApproveRecordToJson(CaseApproveRecord entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['createdAt'] = entity.createdAt;
  data['updatedAt'] = entity.updatedAt;
  data['id'] = entity.id;
  data['caseId'] = entity.caseId;
  data['uid'] = entity.uid;
  data['type'] = entity.type;
  data['approve'] = entity.approve;
  data['remark'] = entity.remark;
  data['approverName'] = entity.approverName;
  return data;
}

extension CaseApproveRecordExtension on CaseApproveRecord {
  CaseApproveRecord copyWith({
    int? createdAt,
    int? updatedAt,
    int? id,
    String? caseId,
    String? uid,
    int? type,
    int? approve,
    String? remark,
    String? approverName,
  }) {
    return CaseApproveRecord()
      ..createdAt = createdAt ?? this.createdAt
      ..updatedAt = updatedAt ?? this.updatedAt
      ..id = id ?? this.id
      ..caseId = caseId ?? this.caseId
      ..uid = uid ?? this.uid
      ..type = type ?? this.type
      ..approve = approve ?? this.approve
      ..remark = remark ?? this.remark
      ..approverName = approverName ?? this.approverName;
  }
}

CaseContractFile $CaseContractFileFromJson(Map<String, dynamic> json) {
  final CaseContractFile caseContractFile = CaseContractFile();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    caseContractFile.id = id;
  }
  final String? desc = jsonConvert.convert<String>(json['desc']);
  if (desc != null) {
    caseContractFile.desc = desc;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    caseContractFile.name = name;
  }
  return caseContractFile;
}

Map<String, dynamic> $CaseContractFileToJson(CaseContractFile entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['desc'] = entity.desc;
  data['name'] = entity.name;
  return data;
}

extension CaseContractFileExtension on CaseContractFile {
  CaseContractFile copyWith({
    int? id,
    String? desc,
    String? name,
  }) {
    return CaseContractFile()
      ..id = id ?? this.id
      ..desc = desc ?? this.desc
      ..name = name ?? this.name;
  }
}

CaseOrder $CaseOrderFromJson(Map<String, dynamic> json) {
  final CaseOrder caseOrder = CaseOrder();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    caseOrder.id = id;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    caseOrder.title = title;
  }
  final int? createdAt = jsonConvert.convert<int>(json['createdAt']);
  if (createdAt != null) {
    caseOrder.createdAt = createdAt;
  }
  final int? orderPayStatus = jsonConvert.convert<int>(json['orderPayStatus']);
  if (orderPayStatus != null) {
    caseOrder.orderPayStatus = orderPayStatus;
  }
  final int? orderChargeStatus = jsonConvert.convert<int>(
      json['orderChargeStatus']);
  if (orderChargeStatus != null) {
    caseOrder.orderChargeStatus = orderChargeStatus;
  }
  final String? orderChannelType = jsonConvert.convert<String>(
      json['orderChannelType']);
  if (orderChannelType != null) {
    caseOrder.orderChannelType = orderChannelType;
  }
  final int? orderAmount = jsonConvert.convert<int>(json['orderAmount']);
  if (orderAmount != null) {
    caseOrder.orderAmount = orderAmount;
  }
  final int? marginAmount = jsonConvert.convert<int>(json['marginAmount']);
  if (marginAmount != null) {
    caseOrder.marginAmount = marginAmount;
  }
  final String? agentUid = jsonConvert.convert<String>(json['agentUid']);
  if (agentUid != null) {
    caseOrder.agentUid = agentUid;
  }
  final int? collectionDate = jsonConvert.convert<int>(json['collectionDate']);
  if (collectionDate != null) {
    caseOrder.collectionDate = collectionDate;
  }
  final String? agentUsername = jsonConvert.convert<String>(
      json['agentUsername']);
  if (agentUsername != null) {
    caseOrder.agentUsername = agentUsername;
  }
  final String? invoice = jsonConvert.convert<String>(json['invoice']);
  if (invoice != null) {
    caseOrder.invoice = invoice;
  }
  final String? createdAtStr = jsonConvert.convert<String>(
      json['createdAtStr']);
  if (createdAtStr != null) {
    caseOrder.createdAtStr = createdAtStr;
  }
  final String? collectionDateStr = jsonConvert.convert<String>(
      json['collectionDateStr']);
  if (collectionDateStr != null) {
    caseOrder.collectionDateStr = collectionDateStr;
  }
  final String? orderAmountStr = jsonConvert.convert<String>(
      json['orderAmountStr']);
  if (orderAmountStr != null) {
    caseOrder.orderAmountStr = orderAmountStr;
  }
  final String? marginAmountStr = jsonConvert.convert<String>(
      json['marginAmountStr']);
  if (marginAmountStr != null) {
    caseOrder.marginAmountStr = marginAmountStr;
  }
  final CaseInvoiceEntity? invoiceInfo = jsonConvert.convert<CaseInvoiceEntity>(
      json['invoiceInfo']);
  if (invoiceInfo != null) {
    caseOrder.invoiceInfo = invoiceInfo;
  }
  return caseOrder;
}

Map<String, dynamic> $CaseOrderToJson(CaseOrder entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['title'] = entity.title;
  data['createdAt'] = entity.createdAt;
  data['orderPayStatus'] = entity.orderPayStatus;
  data['orderChargeStatus'] = entity.orderChargeStatus;
  data['orderChannelType'] = entity.orderChannelType;
  data['orderAmount'] = entity.orderAmount;
  data['marginAmount'] = entity.marginAmount;
  data['agentUid'] = entity.agentUid;
  data['collectionDate'] = entity.collectionDate;
  data['agentUsername'] = entity.agentUsername;
  data['invoice'] = entity.invoice;
  data['createdAtStr'] = entity.createdAtStr;
  data['collectionDateStr'] = entity.collectionDateStr;
  data['orderAmountStr'] = entity.orderAmountStr;
  data['marginAmountStr'] = entity.marginAmountStr;
  data['invoiceInfo'] = entity.invoiceInfo?.toJson();
  return data;
}

extension CaseOrderExtension on CaseOrder {
  CaseOrder copyWith({
    String? id,
    String? title,
    int? createdAt,
    int? orderPayStatus,
    int? orderChargeStatus,
    String? orderChannelType,
    int? orderAmount,
    int? marginAmount,
    String? agentUid,
    int? collectionDate,
    String? agentUsername,
    String? invoice,
    String? createdAtStr,
    String? collectionDateStr,
    String? orderAmountStr,
    String? marginAmountStr,
    CaseInvoiceEntity? invoiceInfo,
  }) {
    return CaseOrder()
      ..id = id ?? this.id
      ..title = title ?? this.title
      ..createdAt = createdAt ?? this.createdAt
      ..orderPayStatus = orderPayStatus ?? this.orderPayStatus
      ..orderChargeStatus = orderChargeStatus ?? this.orderChargeStatus
      ..orderChannelType = orderChannelType ?? this.orderChannelType
      ..orderAmount = orderAmount ?? this.orderAmount
      ..marginAmount = marginAmount ?? this.marginAmount
      ..agentUid = agentUid ?? this.agentUid
      ..collectionDate = collectionDate ?? this.collectionDate
      ..agentUsername = agentUsername ?? this.agentUsername
      ..invoice = invoice ?? this.invoice
      ..createdAtStr = createdAtStr ?? this.createdAtStr
      ..collectionDateStr = collectionDateStr ?? this.collectionDateStr
      ..orderAmountStr = orderAmountStr ?? this.orderAmountStr
      ..marginAmountStr = marginAmountStr ?? this.marginAmountStr
      ..invoiceInfo = invoiceInfo ?? this.invoiceInfo;
  }
}